//
//  TableView.m
//  CommentsTableView
//
//  Created by Gamefire on 16/4/20.
//  Copyright © 2016年 Gamefire. All rights reserved.
//

#import "DetailsTableView.h"
#import "CustomDetailsTableViewCell.h"
#import "ThumbView.h"
@interface DetailsTableView ()<UITableViewDelegate, UITableViewDataSource>

@property (nonatomic,strong)UITableView *tableView;
@property (nonatomic,strong)NSMutableArray *nsmutableArr;

@end



@implementation DetailsTableView

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        _tableView = [[UITableView alloc] initWithFrame:self.bounds style:UITableViewStylePlain];
        [_tableView setDelegate:self];
        [_tableView setDataSource:self];
        [self addSubview:_tableView];
        [_tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
        _nsmutableArr = [NSMutableArray array];
    }
    return self;
}




- (void)setCommitInfo:(NSDictionary *)dic
{
    
}





#pragma mark Delegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

    return 60;

}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

    return 6;

}


- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    if (section == 0) {
        UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 41)];
        [headerView setBackgroundColor:[UIColor whiteColor]];
        
        UIView *topView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 10)];
        [topView setBackgroundColor:[UIColor colorWithRed:236.0/ 255.0 green:236.0/255.0 blue:236.0/255.0 alpha:1]];
        [headerView addSubview:topView];
        
        UILabel *commentlabel = [[UILabel alloc] initWithFrame:CGRectMake(8, 15, 30, 20)];
        [commentlabel setText:@"评论"];
        [commentlabel setFont:[UIFont systemFontOfSize:15.0]];
        [commentlabel setTextAlignment:NSTextAlignmentCenter];
        [commentlabel setTextColor:[UIColor colorWithRed:89.0 /255.0 green:89.0 / 255.0 blue:89.0 /255.0 alpha:1]];
        [headerView addSubview:commentlabel];
        
        UILabel *morelabel = [[UILabel alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width - 69, 15, 60, 20)];
        [morelabel setTextAlignment:NSTextAlignmentCenter];
        [morelabel setFont:[UIFont systemFontOfSize:15.0]];
        [morelabel setText:@"查看更多"];
        [morelabel setTextColor:[UIColor colorWithRed:50.0/255.0 green:50.0/255.0 blue:50.0/255.0 alpha:1]];
        [headerView addSubview:morelabel];
        return headerView;
    }
    return nil;
}


- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    if (section == 0) {
        return 48;
    }
    return 0;
}


#pragma mark DataSource
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *identifier = @"identifier";
    
    CustomDetailsTableViewCell *Cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (Cell == nil) {
        Cell = [[CustomDetailsTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
    }
    return Cell;
}
@end
